$(function(){
	//加载数据
	loadDatas();
	
	//初始化日期控件
  	$('#bt, #et').datetimepicker({
  		language: 'zh-CN',
	    format: 'yyyy-mm-dd',
	    autoclose: true,
	    minView: "month"
	});
	
});

function loadDatas(s){
	if(s=="search"){
		$("#page").val("");
	}
	
	var pageSize = 40;//一页显示的条数
	var begin = $("#begin_time").val();//开始时间
	var end = $("#end_time").val();//结束时间
	var page = $("#page").val();//页码
	
//	alert("begin: "+begin+"; end:"+end+"; page:"+page);
	
	$.ajax({
		type: "post",
		data: {"begin":begin, "end":end, "page":page},
		url: "/admin/platform/platformDetailsRecording",
		beforeSend: function(){
			$("#load").css("display","block");
		},
		success: function(msg){
			$("#load").css("display","none");
			
			//表格数据
			var datas = msg.records;
			var html = "";
			if(datas.length == 0){
				html += "<tr><td colspan='13' align='center'>没查询到符合条件的数据~</td></tr>";
			}else{
				for(var i = 0; i<datas.length; i++){
					html += "<tr>";
					var time = datas[i].writeDate;
					html += "<td>"+time+"</td>";

					var reg = datas[i].todayreg
					if(time < '2016-11-11'){
						reg *= 3;
					}
					html += "<td>"+reg+"</td>";
					html += "<td>"+datas[i].todaymoney+"</td>";
					html += "<td>"+datas[i].maxonline+"</td>";
					html += "<td>"+datas[i].totalscore+"</td>";
					html += "<td>"+datas[i].sendscore+"</td>";
					html += "<td>"+datas[i].czscore+"</td>";
					html += "<td>"+datas[i].totalprizes+"</td>";
					html += "<td>"+datas[i].sendprizes+"</td>";
					html += "<td>"+datas[i].dhprizes+"</td>";
					html += "<td>"+datas[i].xtsy+"</td>";
					html += "<td>"+datas[i].zsc+"</td>";
					html += "<td>"+doubleFormat(datas[i].zsb)+"</td>";
					html += "</tr>";
				}
			}
			$("#databody").html(html);
			
			//统计数据
			var countInfo = msg.countInfo;
			$("#czscore").html(countInfo.czscore==""?0:countInfo.czscore);//总充值金币
			$("#todaymoney").html(countInfo.todayMoney==""?0:countInfo.todayMoney);//总充值元
			$("#xtsy").html(countInfo.xtsy==""?0:countInfo.xtsy);//系统总输赢
			$("#sendscore").html(countInfo.sendscore==""?0:countInfo.sendscore);//总赠送金币
			$("#sendprizes").html(countInfo.sendprizes==""?0:countInfo.sendprizes);//总赠送奖券
			
			//分页数据
			var pageInfo = msg.pageInfo;
			//总条数
			var allCount = pageInfo.count;
			$("#count").html(allCount);
			//总页数
			var allPage = Math.ceil(allCount/pageSize);
			if(allPage==0){
				allPage = 1;
			}
			//当前页码
			var now = pageInfo.page;
			
			$("#page").val(now);
			$("#nowPage").html(now);
			$("#allPage").html(allPage);
			$("#pageIpu").val("");
		}
	});
}

function findAll(s){
	$("#begin_time").val("");
	$("#end_time").val("");
	loadDatas(s);
}